#include <stdlib.h>
#include <stdio.h>

struct ST {
	int key;
	int value;
};

static int compare(const void* a, const void* b) {
	return *(int*)a < *(int*)b;
}

static int compare2(const void* a, const void* b) {
	return ((ST*)a)->key >= ((ST*)b)->key;
}

static void test() {
	int a[] = { 1,9,7,4, 6,5,4,10 };
	int n = sizeof(a) / sizeof(int);
	qsort(a, n, sizeof(int), compare);
	for (int i = 0; i < n; i++)
		printf("%d ", a[i]);
	printf("\n");

	ST b[] = { {1,2},{1,3},{7,9},{7,5},{8,10} };
	n = sizeof(b) / sizeof(ST);
	qsort(b, n, sizeof(ST), compare2);
	for (int i = 0; i < n; i++)
		printf("(%d, %d) ", b[i].key, b[i].value);
	printf("\n");

}


int main_qsort() {
	test();
	return 0;
}